package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author Ahang
 * @description
 * @create 2025-07-23 00:49
 */
@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {
    @Override
    public ItemType convert(String source) {
        ItemType[] values = ItemType.values();
        for (ItemType value : values) {
            if (source.equals(value.getCode()+"")) {
                return value;
            }
        }
        throw new RuntimeException("没有此类型");
    }
}
